package com.hangzhou.welbeing.welbeinginstrument.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hangzhou.welbeing.welbeinginstrument.R;
import com.hangzhou.welbeing.welbeinginstrument.adapter.MainViewpagerAdapter;
import com.hangzhou.welbeing.welbeinginstrument.utils.Utils;
import com.hangzhou.welbeing.welbeinginstrument.view.CustomViewPager;

import java.text.SimpleDateFormat;
import java.util.Date;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * 时间 2017 年 08 月 10.
 * 作者 Administrator  刘传华
 * 公司 杭州惟君医疗科技有限公司
 * 包名 com.hangzhou.welbeing.pregnant.welbeing_pregnant.activity
 * 工程名 welbeing_pregnant
 */
public class MainActivity extends FragmentActivity {
    @Bind(R.id.activity_main_fl_01)
    FrameLayout activityMainFl01;
    @Bind(R.id.activity_main_rl_home_page)
    RelativeLayout activityMainrlHomePage;
    @Bind(R.id.activity_main_rl_circle)
    RelativeLayout activityMainrlCircle;
    @Bind(R.id.activity_main_rl_wechat_mall)
    RelativeLayout activityMainrlWechatMall;
    @Bind(R.id.activity_main_rl_me)
    RelativeLayout activityMainrlMe;

    @Bind(R.id.activity_main_iv_home)
    ImageView activityMainIvHome;
    @Bind(R.id.activity_main_tv_home)
    TextView activityMainTVHome;
    @Bind(R.id.activity_main_iv_circle)
    ImageView activityMainIvCircle;
    @Bind(R.id.activity_main_tv_circle)
    TextView activityMainTVCircle;
    @Bind(R.id.activity_main_iv_wechat_mall)
    ImageView activityMainIvWechatMall;
    @Bind(R.id.activity_main_tv_wechat_mall)
    TextView activityMainTVWechatMall;
    @Bind(R.id.activity_main_iv_me)
    ImageView activityMainIvMe;
    @Bind(R.id.activity_main_tv_me)
    TextView activityMainTVMe;
    @Bind(R.id.activity_main_fl_view_pager)
    CustomViewPager activityMainViewPager;
    private MainViewpagerAdapter mainViewpagerAdapter;
    private boolean flag = true;
    private boolean flag_01 = true;
    private boolean flag_02 = false;
    private boolean flag_03 = false;
    private boolean flag_04 = false;
    private boolean flag_05 = false;
    private int i = 60;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        Utils.setStatusBar(this, false, false);
        Utils.setStatusBar(this, false, false);
        Utils.setStatusTextColor(true, this);
        mainViewpagerAdapter = new MainViewpagerAdapter(getSupportFragmentManager());
        this.activityMainViewPager.setScanScroll(false);
        this.activityMainViewPager.setAdapter(this.mainViewpagerAdapter);
        bottomColumn(R.id.activity_main_rl_home_page);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd");
        sdf.format(new Date());
        //Log.e("tag","+++++loadDate+++=========date============++++"+sdf.format(new Date()));
    }

    @OnClick({R.id.activity_main_rl_home_page,
            R.id.activity_main_rl_circle,
            R.id.activity_main_rl_wechat_mall,
            R.id.activity_main_rl_me})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.activity_main_rl_home_page:
                bottomColumn(R.id.activity_main_rl_home_page);
                break;
            case R.id.activity_main_rl_circle:
               bottomColumn(R.id.activity_main_rl_circle);
                break;
            case R.id.activity_main_rl_wechat_mall:
                bottomColumn(R.id.activity_main_rl_wechat_mall);
                break;
            case R.id.activity_main_rl_me:
                bottomColumn(R.id.activity_main_rl_me);
                break;
        }
    }

    private void bottomColumn(int id) {
        Utils.setStatusTextColor(true, MainActivity.this);
        if (id == R.id.activity_main_rl_home_page) {
            activityMainIvHome.setImageResource(R.mipmap.home_page_01);
            activityMainTVHome.setTextColor(0xffffb3b3);
            activityMainViewPager.setCurrentItem(0);

        } else {
            activityMainIvHome.setImageResource(R.mipmap.home_page);
            activityMainTVHome.setTextColor(0xff909090);
        }

        if (id == R.id.activity_main_rl_circle) {
            activityMainIvCircle.setImageResource(R.mipmap.circle_01);
            activityMainTVCircle.setTextColor(0xffffb3b3);
            activityMainViewPager.setCurrentItem(1);
        } else {
            activityMainIvCircle.setImageResource(R.mipmap.circle);
            activityMainTVCircle.setTextColor(0xff909090);
        }

        if (id == R.id.activity_main_rl_wechat_mall) {
            activityMainIvWechatMall.setImageResource(R.mipmap.mall_01);
            activityMainTVWechatMall.setTextColor(0xffffb3b3);
            activityMainViewPager.setCurrentItem(2);
        } else {
            activityMainIvWechatMall.setImageResource(R.mipmap.mall);
            activityMainTVWechatMall.setTextColor(0xff909090);

        }

        if (id == R.id.activity_main_rl_me) {
            activityMainIvMe.setImageResource(R.mipmap.me_01);
            activityMainTVMe.setTextColor(0xffffb3b3);
            activityMainViewPager.setCurrentItem(3);
        } else {
            activityMainIvMe.setImageResource(R.mipmap.me);
            activityMainTVMe.setTextColor(0xff909090);
        }
    }

    }
